<template>
  <div class="collect">
    <div class="collect-header">
      <div class="collect-title">
        <i class="el-icon-collection-tag"></i>
        我的收藏
      </div>
      <div class="collect-subtitle">珍藏您的心仪之物</div>
    </div>
    <div class="content">
      <div class="goods-list" v-if="collectList.length>0">
        <MyList :list="collectList" :isDelete="true"></MyList>
      </div>
      <div v-else class="collect-empty">
        <div class="empty">
          <div class="empty-icon">
            <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="#ff6700" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
              <path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"></path>
            </svg>
          </div>
          <h2>您的收藏还是空的！</h2>
          <p>发现更多精彩，开始您的收藏之旅</p>
          <button class="browse-btn" @click="$router.push('/')">去逛逛</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      collectList: []
    };
  },
  activated() {
    this.$axios
      .post("/api/user/collect/getCollect", {
        user_id: this.$store.getters.getUser.user_id
      })
      .then(res => {
        if (res.data.code === "001") {
          this.collectList = res.data.collectList;
        }
      })
      .catch(err => {
        return Promise.reject(err);
      });
  }
};
</script>

<style>
.collect {
  background-color: #f8f8f8;
  min-height: 100vh;
}

.collect-header {
  background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
  padding: 40px 0 30px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(255, 103, 0, 0.1);
  margin-bottom: 30px;
}

.collect-title {
  font-size: 36px;
  font-weight: 600;
  color: white;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.collect-title i {
  margin-right: 15px;
  font-size: 40px;
  color: white;
}

.collect-subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 1px;
}

.content {
  width: 1225px;
  margin: 0 auto;
  padding: 20px 0 50px;
}

.goods-list {
  display: flex;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 25px;
  margin-top: 20px;
}

.collect-empty {
  background: white;
  border-radius: 12px;
  padding: 60px 20px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.empty-icon {
  margin-bottom: 25px;
}

.empty h2 {
  font-size: 28px;
  color: #333;
  margin-bottom: 15px;
  font-weight: 500;
}

.empty p {
  font-size: 16px;
  color: #888;
  margin-bottom: 30px;
}

.browse-btn {
  background: linear-gradient(to right, #ff6700, #ff9a44);
  color: white;
  border: none;
  padding: 12px 36px;
  font-size: 16px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(255, 103, 0, 0.3);
}

.browse-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 103, 0, 0.4);
}

.browse-btn:active {
  transform: translateY(0);
}
</style>